import axios from 'axios'
import NProgress from 'nprogress'
import "nprogress/nprogress.css"
import { GET_TOKEN } from './token-utils'
const request2 = axios.create({
    baseURL: '/api',
    timeout: 20000
})
request2.interceptors.request.use(config => {
    config.headers.token = GET_TOKEN()
    NProgress.start()
    return config
}, err => {
    NProgress.done()
    return Promise.reject(err)
})
request2.interceptors.response.use(response => {
    NProgress.done()
    return response.data
}, err => {
    NProgress.done()
    console.error(err)
    return Promise.reject(err)
})
export default request2